﻿using CommonLib;
using CommonLib.Extension;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 战斗界面的外观类
/// </summary>

public class GamePlayFacade : LazySingleton<GamePlayFacade>
{

	public BattleLogic Sub_Battle { get; protected set; }
	public SkillLogic Sub_Skill { get; protected set; }

	protected GamePlayFacade()
	{
		Sub_Battle = GameObject.FindObjectOfType<BattleLogic>();
		Sub_Skill = GameObject.FindObjectOfType<SkillLogic>();
	}

	public void Init()
	{

		var LevelEntity = JsonExtension.ReadJson<List<BattleLevelEntity>>(
			GameResourceLoader.Instance.LoadFromResource<TextAsset>(
				GameResource.DocumentResMgr.GetPath(AppPath.Resource, "Level/BattleLevelFile2")
				).text
			)[0];
		if (null != LevelEntity)
		{
			Debug.Log("EnterBattle");
		}
		else
		{
			Debug.Log("EnterBattle Fiale");
		}


		//Input BattleLevelEntity
		Sub_Battle.Init(this, LevelEntity);
		Sub_Skill.Init(this);


		//开启战斗
		Sub_Battle.ReceiveSceneEvent((int)SceneEvent.EVENT_SCENE_START, (int)Scene.BattleScene);
	}

	public void DoUpdate(float deltaTime)
	{
			Sub_Battle.DoUpdate(deltaTime);
			Sub_Skill.DoUpdate(deltaTime);
		
	}

	public void DoEnd()
	{
		Sub_Battle.Clear();
		Sub_Skill.Clear();
	}

	public void ReceiveSceneEvent(int ev, int evp)
	{
		//TODO 
		Sub_Battle.ReceiveSceneEvent(ev, evp);
	}
}
